"""
1-7月各街道矛盾纠纷堆积图
"""

import matplotlib.pyplot as plt
import numpy as np

months = ["一月", "二月", "三月", "四月", "五月", "六月", "七月"]
data = [
    [81, 81, 76, 77, 138, 163, 124],  # 凌水
    [108, 106, 93, 86, 91, 56, 108],  # 七贤岭
    [26, 25, 25, 26, 86, 66, 93],  # 龙王塘
]
labels = ["凌水", "七贤岭", "龙王塘"]
colors = ["blue", "red", "green", "yellow", "purple"]
sum_data = [sum(x) for x in data]
sum_label = [f"{label}累计排查量{num}" for num, label in zip(sum_data, labels)]


plt.stackplot(months, data, labels=sum_label, colors=colors)

# 设置中文用楷体
plt.rcParams["font.sans-serif"] = ["KaiTi"]

plt.legend(loc="upper left")
plt.grid(True)
plt.title(f"1-{len(months)}月街道矛盾纠纷排查量")

# 显示图形
plt.show()
